﻿using System.Xml.Serialization;
using PrearrangedChaos.AgileZen.Service.Rest;

namespace PrearrangedChaos.AgileZen.Service.Model
{
    [XmlType(AnonymousType = true)]
    [XmlRootAttribute(ElementName = "tag", Namespace = "", IsNullable = false)]
    [ZenRestRequest("projects/{ProjectId}/tags/{Tag}")]
    public class TagUpdater : ModelBase, ITagUpdater
    {
        private string _name;

        [XmlElement(ElementName = "name")]
        public string NameXmlElement
        {
            get { return _name; }
            set
            {
                if (!string.IsNullOrEmpty(value))
                    _name = value;
                else
                    _name = null;

                this.Unmodified("name");
            }
        }

        [XmlIgnore]
        public string Name
        {
            get { return _name; }
            set
            {
                if (_name == value)
                    return;

                _name = value;
                this.Modified("name");
            }
        }

        public bool NameXmlElementSpecified { get { return this.IsModified("name"); } }
    }
}